const { findNavListService } = require("../../service/navs");
const { ErrorRes, SuccessRes } = require("../../res-model/index");
const { findNavListFailInfo } = require("../../res-model/failInfo/navs");
/**
 * 查询所有导航
 */
async function findNavList() {
  let navs;
  try {
    navs = await findNavListService();
  } catch (ex) {
    console.error("查询导航列表", ex);
    return new ErrorRes(findNavListFailInfo); // 数据库错误
  }
  // 查询失败
  if (navs == null)
    return new ErrorRes(findNavListFailInfo, "导航栏列表数据不存在");

  // 查询成功
  return new SuccessRes(Array.from(navs));
}
module.exports = {
  findNavList,
};
